<template>
  <div class="public">
    <p @click="toChangeCity">{{ address }}</p>
    <van-tabs v-model="active" sticky @click="changeActive">
      <van-tab v-for="(item, idx) in tabList" :key="idx" :title="item">
            <div v-for="(val, i) in list" :key="i" class="classify-item">
                <!-- <img v-for="img in imageList" v-lazy="img" /> -->
                <!-- <img  v-lazy="val.img"  alt=""> -->
                <img v-lazy-container="{selector: val.img, loading: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_match%2F0%2F10559394992%2F0.jpg&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1631436187&t=6631193e1a66b71441b24c032d75af10'}" alt="">
                <div class="classify-info">
                    <h3>{{val.listingTitle}}</h3>
                    <div>
                        {{val.area}}|建面{{val.houseArea}}
                    </div>
                    <p>{{val.sellingprice}}/套</p>
                </div>
            </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { mapState } from "vuex";
// import data from "@/utils/house.js";
import { getRcommendData } from '@/api'
export default {
  name: "mains",
  data() {
      return {
        active: 1,
          list: [],
          tabList: ['新房','二手房','商铺','写字楼','租房']
      }
  },
  computed: {
    ...mapState(["address"]),
  },
  created() {

    this.getRcommendData()
  },
  methods: {
    toChangeCity() {
      this.$router.push("/changecity");
    },
    changeActive(e) {
        this.active = e

        this.getRcommendData()
    },
    getRcommendData() {
        getRcommendData({classify: this.active + 1}).then(res => {
            this.list = res.data
        })
    }
  },
};
</script>

<style lang="scss" scoped>
.classify-item {
    display: flex;
    padding: 10px;
    img {
        width: 100px;
        height: 100px;
    }
    .classify-info {
        display: flex;
        flex-direction: column;
        padding-left: 10px;
        justify-content: space-between;
    }
}
</style>